package com.xr.wage.commonTools;

import com.bstek.dorado.common.*;
import com.bstek.dorado.data.*;
import com.bstek.dorado.data.db.DBStatement;
import com.bstek.dorado.view.*;
import com.bstek.dorado.view.data.*;
import com.bstek.dorado.view.control.*;
import com.xr.common.CommUtil;

/**
 * warningSetViewModel
 */
public class warningSetViewModel extends DefaultViewModel {
  protected void doUpdateData(ParameterSet parameters, ParameterSet outParameters)
      throws Exception {
    // Add your code here
    super.doUpdateData(parameters, outParameters);
  }

 
	protected void initControls() throws Exception {
		super.initControls();
		if(getConfigName().equals("com.xr.wage.commonTools.warningSetLimit")){
			Dataset ds =getDataset("datasetWarningLimit");
			 int warningType=ds.parameters().getInt("WARNING_TYPE");
			ViewField ee = (ViewField) ds.getField("JOIN_KEY_NAME");
			ee.setDropDown("dropdown"+warningType);
		}
		
	}
	public void WarningSave(ParameterSet parameters, ParameterSet outParameters)
    throws Exception {
		  DBStatement dbs = new DBStatement();
		  Dataset ds = getDataset("datasetWarning");
		  
		  RecordIterator ri = ds.recordIterator();
		  ri.setVisibility(Dataset.FILTER_DELETED);
		  while (ri.hasNext()) {
		    Record record = ri.nextRecord();
		    dbs.setSql("delete from WA_WARNING_LIMIT where WA_WARNING_ID="+record.getString("WA_WARNING_ID"));
		    dbs.execute();
		    dbs.setSql("delete from WA_WARNING where WA_WARNING_ID="+record.getString("WA_WARNING_ID"));
		    dbs.execute();
		  }
		  
//		  ds.setValue("CREATE_ID", CommUtil.getEmployeeId());
//		  ds.setValue("CREATE_DATE", new java.util.Date());
		  CommUtil.dbsUpdateData(dbs, ds, "WA_WARNING", "WA_WARNING_ID","SEQ_WA");
		  dbs.close();
  //super.doUpdateData(parameters, outParameters);
	}
	public void WarningLimitSave(ParameterSet parameters, ParameterSet outParameters)
      throws Exception {
		  DBStatement dbs = new DBStatement();
		  Dataset ds = getDataset("datasetWarningLimit");
		  
		  RecordIterator ri = ds.recordIterator();
		  ri.setVisibility(Dataset.FILTER_DELETED);
		  while (ri.hasNext()) {
		    Record record = ri.nextRecord();
		    dbs.setSql("delete from WA_WARNING_LIMIT where WA_WARNING_LIMIT_ID="+record.getString("WA_WARNING_LIMIT_ID"));
		    dbs.execute();
		  }
		  
//		  ds.setValue("CREATE_ID", CommUtil.getEmployeeId());
//		  ds.setValue("CREATE_DATE", new java.util.Date());
		  CommUtil.dbsUpdateData(dbs, ds, "WA_WARNING_LIMIT", "WA_WARNING_LIMIT_ID","SEQ_WA");
		  dbs.close();
    //super.doUpdateData(parameters, outParameters);
  }

 
	
}
